package com.LachesismStorm.lachesism.member.controller;

import com.LachesismStorm.lachesism.core.common.response.ResponseResult;
import com.LachesismStorm.lachesism.member.dto.UmsMemberParam;
import com.LachesismStorm.lachesism.member.service.UmsMemberService;
import com.LachesismStorm.lachesism.member.vo.MemberUpdateParam;
import com.LachesismStorm.lachesism.member.vo.MessageVO;
import com.LachesismStorm.lachesism.member.vo.NoteVO;
import com.LachesismStorm.lachesism.member.vo.UmsMember;
import io.swagger.annotations.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.LinkedHashMap;


@RestController
@Api(tags = "用户登录注册管理")
@RequestMapping("/sso/member")
public class UmsMemberController {

    @Resource
    private UmsMemberService memberService;


    @ApiOperation(value = "用户手机号登录注册")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "UmsMemberParam", value = "用户注册信息")
    })
    @PostMapping("/loginByPhone")
    public ResponseResult loginByPhone(@RequestBody UmsMemberParam memberParam) {
        String token = memberService.loginByPhone(memberParam);
        return ResponseResult.success(token, "登录成功");
    }

    @ApiOperation(value = "发送短信")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "UmsMemberParam", value = "用户手机号")
    })
    @PostMapping("/sendMessage")
    public ResponseResult sendMessage(@RequestBody UmsMemberParam memberParam) {
        memberService.sendMessage(memberParam);
        return ResponseResult.success(null, "发送成功");
    }

    @ApiOperation(value = "获取用户信息")
    @PostMapping("/getUserInfo")
    public ResponseResult getUserInfo() {
        UmsMember umsMember = memberService.getUserInfo();
        return ResponseResult.success(umsMember, "查找成功");
    }

    @ApiOperation(value = "更新用户信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "UmsMemberParam", value = "用户手机号")
    })
    @PostMapping("/updateMemberInfo")
    public ResponseResult updateMemberInfo(@RequestBody UmsMember umsMember) {
        memberService.updateMemberInfo(umsMember);
        return ResponseResult.success(null, "更新成功");
    }


    @ApiOperation(value = "发送消息")
    @PostMapping("/sendAMessage")
    public ResponseResult sendAMessage(@RequestBody MessageVO messageVO) {
        memberService.sendAMessage(messageVO);
        return ResponseResult.success(null, "发送成功");
    }


}
